
function NewVerse(Verse)
{
 var startTime = GetTime();
 RenderMap();
 WindowStyle.drawWindow (100, 385, 440, 60);
 Font.drawTextBox (125, 395, 500, 100, 5, Verse);
 FlipScreen();
 eatKey()
	while (true)
	{
		if (GetTime() - startTime > 100 && AreKeysLeft())
		{
			switch (GetKey())
			{
				case KEY_ENTER:
				{
				eatKey();
				return;
				}
				case KEY_SPACE:
				{
				eatKey();
				return;
				}
			}
		}
	}
}

function Verse_Window(Verse)
{
 var startTime = GetTime();
 RenderMap();
 WindowStyle.drawWindow (25, 385, 590, 60);
 Font.drawTextBox (40, 395, 600, 100, 5, Verse);
 FlipScreen();
 eatKey()
	while (true)
	{
		if (GetTime() - startTime > 100 && AreKeysLeft())
		{
			switch (GetKey())
			{
				case KEY_ENTER:
				{
				eatKey();
				return;
				}
				case KEY_SPACE:
				{
				eatKey();
				return;
				}
			}
		}
	}
}

function Sing(place)
{
  if (placeT[place] <= Player.day)
  {
  placeT[place] = Player.day + 8;
  
    if (Math.random() <= 0.20)
    {
    RandomSong(1);
    }
    else if (Math.random() <= 0.25)
    {
    RandomSong(2);
    }
    else if (Math.random() <= 0.33)
    {
    RandomSong(3);
    }
    else if (Math.random() <= 0.50)
    {
    RandomSong(4);
    }
    else
    {
    RandomSong(5);
    }    
  }
  else
  {
  Talk_Window("You've already sang here recently.  Wait a few more days.", "blank.png");
  }

}

function RandomSong(songnum)
{
SetPersonDirection("main character", 4);
SetPersonFrame("main character", 0);

  if (songnum == 1)
  {
  Talk_Window(Player.name + ": Ladies and gentlemen!  I give you the song: @#%!! $@%#!!", Player.port);
  SetPersonDirection("main character", 8);
  SetPersonFrame("main character", 9);
  NewVerse("\n                   (Censored)");
  Talk_Window("Man:  Will you shut up if we give you some money?", "blank.png");
  SetPersonDirection("main character", 4);
  SetPersonFrame("main character", 0);
  Delay(200);
  Talk_Window(Player.name + ": Yes.", Player.port);
  Delay(200);
  Talk_Window("Man:  Then take this!", "blank.png");
  Player.numtemp = Math.floor(250*(Player.luck/30)*(Math.random()/5 + 0.9));
  Delay(200);
  }
  else if (songnum == 2)
  {
  Talk_Window(Player.name + ": Ladies and gentlemen!  I give you the Blah song!", Player.port);
  SetPersonDirection("main character", 8);
  SetPersonFrame("main character", 9);
  NewVerse("Blah blah blah song! \n What to do? \n Wow! \n man...");
  Player.numtemp = Math.floor(250*(Player.luck/30)*(Math.random()/5 + 0.9));
  Delay(200);
  }
  else if (songnum == 3)
  {
  Talk_Window(Player.name + ": Ladies and gentlemen!  I give you the Blah song!", Player.port);
  SetPersonDirection("main character", 8);
  SetPersonFrame("main character", 9);
  NewVerse("Blah blah blah song! \n What to do? \n Wow! \n man...");
  Player.numtemp = Math.floor(250*(Player.luck/30)*(Math.random()/5 + 0.9));
  Delay(200);
  }
  else if (songnum == 4)
  {
  Talk_Window(Player.name + ": Ladies and gentlemen!  I give you the Blah song!", Player.port);
  SetPersonDirection("main character", 8);
  SetPersonFrame("main character", 9);
  NewVerse("Blah blah blah song! \n What to do? \n Wow! \n man...");
  Player.numtemp = Math.floor(250*(Player.luck/30)*(Math.random()/5 + 0.9));
  Delay(200);
  }
  else if (songnum == 5)
  {
  Talk_Window(Player.name + ": Ladies and gentlemen!  I give you the Blah song!", Player.port);
  SetPersonDirection("main character", 8);
  SetPersonFrame("main character", 9);
  NewVerse("Blah blah blah song! \n What to do? \n Wow! \n man...");
  Player.numtemp = Math.floor(250*(Player.luck/30)*(Math.random()/5 + 0.9));
  Delay(200);
  }
  SetPersonDirection("main character", 4);
  SetPersonFrame("main character", 0);
  Player.gp = Player.gp + Player.numtemp;
  eatKey();
  Talk_Window("Received " + Player.numtemp + " Gp!", Player.port);
}

function OrexSing()
{
Talk_Window(Player.name + ": Let me guess, the town's favorite - 'Darby Ram' right?", Player.port);
Delay(200);
Talk_Window("Gerald: You got it!  Let's hear it!", "blank.png");
Delay(200);
Talk_Window(Player.name + ": Ok. here we go people.  The Darby Ram.", Player.port);
Delay(200);
SetPersonDirection("main character", 8);
SetPersonFrame("main character", 9);

  Verse_Window("As I went down to Darby, t'was on a summer's day,\nI spied the finest ram, sir, that ever was fed on hay.\nNow the horns upon this ram, sir, they reached up to the moon\nAnd the man who climbed up in Janu'ry never came back til June.");

  //Chorus
  Verse_Window("And indeed me lads, it's true me lads, I've never been known to lie\nAnd if you had been in Darby you'd have seen the same as I.");

  Verse_Window("Now the tail upon this ram, sir, it grew down into hell\nAnd every time he waggled it he rang the fireman's bell,\nAnd the horns upon this ram, sir, they grew so mighty wide\nThat a coach and six could go betwixt with a coachman by their side.")

  //Chorus
  Verse_Window("And indeed me lads, it's true me lads, I've never been known to lie\nAnd if you had been in Darby you'd have seen the same as I.");

  Verse_Window("Now the whool upon this ram, sir, it grew so fast as sin\nAnd it took all the women in Darby town a hundred years to spin,\nNow the man who killed this ram, sir, he got drowned in the blood\nAnd all the rest of the men, sir, got washed out in the flood.");

  Verse_Window("Now the man who owned this ram, sir, he needn't be very rich\nAnd the man who rhymed this song, sir, was a lyin' son of a...");
  //Chorus
  Verse_Window("And indeed me lads, it's true me lads, I've never been known to lie\nAnd if you had been in Darby you'd have seen the same as I.");

  Player.numtemp = Math.floor(250*(Player.luck/30)*(Math.random()/5 + 0.9));
  Delay(200);
  SetPersonDirection("main character", 4);
  SetPersonFrame("main character", 0);
  Player.gp = Player.gp + Player.numtemp;
  Talk_Window("Received " + Player.numtemp + " Gp!", Player.port);

}